/*
 * @Author: xuxu12138 1718324422@qq.com
 * @Date: 2023-10-24 08:07:57
 * @LastEditors: xuxu12138 1718324422@qq.com
 * @LastEditTime: 2023-10-24 14:37:40
 * @FilePath: /things-admin/src/base/api/ComponentApi.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { request } from '@/base/Request';
import { Component } from '@/base/model/Component'
import qs from 'qs'

//按照序列号来查询部件数据
export function findByDeviceSn(deviceSn: string) {
    return request.getArray(Component, `/api/component-maintenance/findByDeviceSn/${deviceSn}`)
}
//新增部件状态
export const addDeviceSn = (params: {
    componentName: string,
    modelId: number,
    usageTime: number,
    warranty: number,
    deviceSn: string,
    code: number

}) => request.post(Component, '/api/component-maintenance', qs.stringify(params))

//删除部件数据
export const deleteData = (
    id: string
) => request.delete(`/api/component-maintenance/${id}`)

//修改部件数据
export const putData = (params: {
    componentName: string,
    modelId: number,
    usageTime: number,
    warranty: number,
    deviceSn: string,
    id: number,
    created: string,
    code: number
}) => request.put(Component, '/api/component-maintenance', qs.stringify(params))

//重置数据
export const resetData = (id: string) => request.put(Component, `/api/component-maintenance/reset/${id}`)

//查询对应数据
export const sreachData = (deviceSn: string) => request.getArray(Component, `/api/component-maintenance/findByDeviceSn/${deviceSn}`)